package com.SmartCare.controller.client;

import com.SmartCare.common.Result;
import com.SmartCare.service.medicine.MedicationRecordService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/client/medication_record")
@Api(tags = "C端用药记录控制器")
@Slf4j
public class MedicineRecordController {
    @Resource
    MedicationRecordService medicationRecordService;

    //根据药单项生成用药记录
    @PostMapping("/add")
    public Result addRecords(@RequestParam Long listId) {
        return medicationRecordService.addRecords(listId);
    }

    //更新用药情况
    @PutMapping("/update")
    public Result updateStatus(@RequestParam Long id, @RequestParam Integer status) {
        return medicationRecordService.updateStatus(id, status);
    }

    //获取老人的全部用药记录
    @GetMapping("/selectAll")
    public Result getAllRecords(@RequestParam Long elderlyId) {
        return medicationRecordService.selectAllRecords(elderlyId);
    }

    //获取老人的当天的用药记录
    @GetMapping("/selectToday")
    public Result selectToday(@RequestParam Long elderlyId) {
        return medicationRecordService.selectToday(elderlyId);
    }
}
